package api

import (
	"gitee.com/chejiangyi/bsfgo/core/base2"
	"gitee.com/chejiangyi/bsfgo/core/utils"
	"gitee.com/chejiangyi/bsfgo/gin2/controller"
	"github.com/gin-gonic/gin"
)

type HttpController struct {
	controller.BaseApiController
}

func (m *HttpController) Test(c *gin.Context) {
	defer m.CatchJsonError(c)
	client := utils.HttpUtil.GetDefaultClient()
	r, err := client.R().Get("http://www.baidu.com")
	m.CheckError(err)
	if !r.IsSuccess() {
		panic(base2.NewBsfBizError("访问百度出错"))
	}
	header := r.Header()
	utils.LogUtil.Info("header:", header)
	m.JsonSuccess(c, string(r.Body()))
}
